#include "basic/memory_pool.h"

namespace basic {
DKMemoryBlock::DKMemoryBlock(unsigned long long n) {
  m_nCapability = n;
  m_pBuffer = (unsigned char *)malloc(n);
}

DKMemoryBlock::~DKMemoryBlock() {
  M_SAFE_FREE(m_pBuffer)
  m_pBuffer = nullptr;
}

void DKMemoryAllocator::SetMemoryBlock(DKMemoryBlock *pb) {
  m_ptrBlock.reset(pb);
  m_pivot = 0u;
  m_range.begin = 0;
  m_range.length = pb->GetPreservingSize();
}

void DKMemoryAllocator::SetMemoryBlock(std::shared_ptr<DKMemoryBlock> b,
                                       const DKSRange<unsigned long long> &&r) {
  m_ptrBlock = b;
  m_pivot = 0u;
  m_range = r;
}
} // namespace basic
